import { createSlice } from "@reduxjs/toolkit";


const userSlice = createSlice({
    name:'userSlice',
    initialState:{
        userInfor:JSON.parse(localStorage.getItem("userinfor") || "{}"),
    },
    reducers:{
        setUserinfor(state,{payload}){
            console.log(payload);
            state.userInfor = payload;
            localStorage.setItem("userinfor",JSON.stringify(state.userInfor));
        }
    }
})
//抛出actions
export const {setUserinfor} = userSlice.actions
//抛出reducer
export default userSlice.reducer